package com.dashan.frontend.client.event;

import com.dashan.frontend.client.widgets.GeoGridPanel.GeoRecord;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.maps.client.overlay.Marker;

public class GeoItemSelectedEvent extends GwtEvent<GeoItemSelectedHandler> {

    private GeoRecord geoRecord;
    private boolean moveToCenter;
    public static final Type<GeoItemSelectedHandler> TYPE = new Type<GeoItemSelectedHandler>();
    
    public GeoItemSelectedEvent(GeoRecord geoRecord) {
        this(geoRecord, false);
    }
    
    public GeoItemSelectedEvent(Marker m) {
        this(new GeoRecord(null, m), false);
    }
    
    public GeoItemSelectedEvent(Marker m, boolean moveToCenter) {
        this(new GeoRecord(null, m), moveToCenter);
    }

    public boolean isMoveToCenter() {
        return moveToCenter;
    }

    public GeoItemSelectedEvent(GeoRecord geoRecord, boolean moveToCenter) {
        this.geoRecord = geoRecord;
        this.moveToCenter = moveToCenter;
    }
    
    public GeoRecord getGeoRecord() {
        return geoRecord;
    }
    
    @Override
    protected void dispatch(GeoItemSelectedHandler handler) {
        handler.onGeoItemSelected(this);
    }

    @Override
    public com.google.gwt.event.shared.GwtEvent.Type<GeoItemSelectedHandler> getAssociatedType() {
        return TYPE;
    }
}
